package Controller;

import entity.empManager;
import service.empManagerService;
import service.impl.empMangagerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ResourceBundle;

/*
 *徐韬
 *2021/9/20
 *13:18
 */
@WebServlet("/login")
public class LoginController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String username = request.getParameter("username");
        String password = request.getParameter("password");



         empManagerService empManagerService = new empMangagerServiceImpl();
        empManager empmanager = empManagerService.login(username, password);



        if(empmanager != null){
          response.sendRedirect("/ems/ShowAllController");
        }else {
          response.sendRedirect("/ems/login.jsp");
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
